﻿<UserControl x:Class="ControleRepresentanteSync.View.Pedido.PedidoListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Pedido="clr-namespace:ControleRepresentanteSync.View.Pedido"
             DataContextChanged="UserControlDataContextChanged">
	<UserControl.Resources>
        <DataTemplate x:Key="IsChecked">
            <CheckBox IsChecked="{Binding Path=IsChecked}" />
        </DataTemplate>
        <DataTemplate x:Key="cliente" DataType="{x:Type Pedido:PedidoViewModel}">
            <TextBlock Text="{Binding Path=Cliente.RazaoSocial}" TextTrimming="CharacterEllipsis" />
        </DataTemplate>
        <DataTemplate x:Key="vendedor" DataType="{x:Type Pedido:PedidoViewModel}">
            <TextBlock Text="{Binding Path=Vendedor.Nome}" TextTrimming="CharacterEllipsis" />
        </DataTemplate>
        <DataTemplate x:Key="fabrica" DataType="{x:Type Pedido:PedidoViewModel}">
            <TextBlock Text="{Binding Path=Fabrica.Nome}" TextTrimming="CharacterEllipsis" />
        </DataTemplate>
        <DataTemplate x:Key="transportadora" DataType="{x:Type Pedido:PedidoViewModel}">
            <TextBlock Text="{Binding Path=Transportadora.Nome}" TextTrimming="CharacterEllipsis" />
        </DataTemplate>
        <DataTemplate x:Key="IsAllChecked">
            <CheckBox Checked="IsAllCheckedChecked" Unchecked="IsAllCheckedChecked" />
        </DataTemplate>
    </UserControl.Resources>
	<ListView ItemsSource="{Binding Path=Contents}" SelectionMode="Single">
        <ListView.View>
            <GridView x:Name="Columns">
                <GridViewColumn x:Name="IsCheckedColumn" HeaderTemplate="{StaticResource IsAllChecked}" CellTemplate="{StaticResource IsChecked}" />
                <GridViewColumn Width="80" Header="Número" DisplayMemberBinding="{Binding Path=Numero}" />
                <GridViewColumn Width="70" Header="Data" DisplayMemberBinding="{Binding Path=Data, StringFormat=\{0:d/M/yyyy\}}" />
                <GridViewColumn Width="134" Header="Cliente" CellTemplate="{StaticResource cliente}" />
                <GridViewColumn Width="134" Header="Vendedor" CellTemplate="{StaticResource vendedor}" />
                <GridViewColumn Width="134" Header="Transportadora" CellTemplate="{StaticResource transportadora}" />
                <GridViewColumn Width="134" Header="Fábrica" CellTemplate="{StaticResource fabrica}" />
                <GridViewColumn Width="50" Header="Peças" DisplayMemberBinding="{Binding Path=Pecas}" />
                <GridViewColumn Width="90" Header="Total Mercadoria" DisplayMemberBinding="{Binding Path=TotalMercadoria, StringFormat=\{0:C\}}" />
            </GridView>
        </ListView.View>
    </ListView>
</UserControl>